﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SystemDirectory.Biz;
using SystemDirectory.Common;
using System.Data;
using SystemDirectory.Entity;

namespace SystemDirectory
{
    public partial class ServiceAmend : System.Web.UI.Page
    {
        public static bool IsCheck = false;
        public static Utilities.SearchType IsSearch;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.QueryString["id"] != null)
                {

                    BOService boService = new BOService();
                    SystemDirectory.Entity.Service sv = boService.GetByID(Convert.ToInt32(Request.QueryString["id"].ToString()));
                    txtServiceName.Text = sv.ServiceName;
                    txtServiceShortDescription.Text = sv.serviceshortdescription;
                    clientdescription.Text = sv.clientdescription;
                    SubType.Text = sv.SubType;
                    LeadContact.Text = sv.Leadcontact;
                    ServiceAttendant.Text = sv.ServiceAttendant;
                    serviceStartDate.Text = sv.serviceStartDate;
                    ServiceStart.Text = sv.ServiceStart;
                    ServiceEnd.Text = sv.ServiceEnd;
                    ServiceExtend.Text = sv.ServiceExtend;
                    ServiceActive.Checked = sv.ServiceActive;
                    DeptCode.Text = sv.DeptCode;
                    ServiceType.Text = sv.ServiceType;
                    DescriptionDelivery.Text = sv.DescriptionDelivery;
                    ContractCode.Text = sv.ContractCode;
                    ContractValue.Text = sv.ContractValue;
                    StagedPayment.Checked = sv.StagedPayment;
                    ServiceTimeLimited.Text = sv.ServiceTimeLimited;
                }
                else
                {
                    Response.Redirect("ProgrammeList.aspx");
                }
                
            }
        }


        protected void TextBox1_TextChanged(object sender, EventArgs e)
        {

        }
        protected void cbxInactive_CheckedChanged(object sender, EventArgs e)
        {
            IsCheck = cbxInactive.Checked;
            BOPremise buContact = new BOPremise();
            DataTable dtContact = buContact.Get(IsCheck, IsSearch);
            rptPremise.DataSource = dtContact;
            rptPremise.DataBind();
        }


        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            IsSearch = Utilities.SearchType.TypeAll;
            BOPremise buContact = new BOPremise();
            DataTable dtContact = buContact.Get(IsCheck, IsSearch);
            rptPremise.DataSource = dtContact;
            rptPremise.DataBind();
        }
        protected void LinkButton2_Click(object sender, EventArgs e)
        {
            IsSearch = Utilities.SearchType.Type09;
            BOPremise buContact = new BOPremise();
            DataTable dtContact = buContact.Get(IsCheck, IsSearch);
            rptPremise.DataSource = dtContact;
            rptPremise.DataBind();

        }

        protected void LinkButton3_Click(object sender, EventArgs e)
        {
            IsSearch = Utilities.SearchType.TypeAE;
            BOPremise buContact = new BOPremise();
            DataTable dtContact = buContact.Get(IsCheck, IsSearch);
            rptPremise.DataSource = dtContact;
            rptPremise.DataBind();
        }

        protected void LinkButton4_Click(object sender, EventArgs e)
        {
            IsSearch = Utilities.SearchType.TypeFJ;
            BOPremise buContact = new BOPremise();
            DataTable dtContact = buContact.Get(IsCheck, IsSearch);
            rptPremise.DataSource = dtContact;
            rptPremise.DataBind();
        }

        protected void LinkButton5_Click(object sender, EventArgs e)
        {
            IsSearch = Utilities.SearchType.TypeKM;
            BOPremise buContact = new BOPremise();
            DataTable dtContact = buContact.Get(IsCheck, IsSearch);
            rptPremise.DataSource = dtContact;
            rptPremise.DataBind();
        }

        protected void LinkButton6_Click(object sender, EventArgs e)
        {
            IsSearch = Utilities.SearchType.TypeOR;
            BOPremise buContact = new BOPremise();
            DataTable dtContact = buContact.Get(IsCheck, IsSearch);
            rptPremise.DataSource = dtContact;
            rptPremise.DataBind();
        }

        protected void LinkButton7_Click(object sender, EventArgs e)
        {
            IsSearch = Utilities.SearchType.TypeSV;
            BOPremise buContact = new BOPremise();
            DataTable dtContact = buContact.Get(IsCheck, IsSearch);
            rptPremise.DataSource = dtContact;
            rptPremise.DataBind();
        }

        protected void LinkButton8_Click(object sender, EventArgs e)
        {
            IsSearch = Utilities.SearchType.TypeWZ;
            BOPremise buContact = new BOPremise();
            DataTable dtContact = buContact.Get(IsCheck, IsSearch);
            rptPremise.DataSource = dtContact;
            rptPremise.DataBind();

        }

        protected void saveService_Click(object sender, EventArgs e)
        {
        
        Page.Validate("vgroup");
        if (Page.IsValid)
        {


            Service sv=new Service();
            sv.ServiceID=Convert.ToInt32(Request.QueryString["id"].ToString());
            sv.ServiceName = txtServiceName.Text;
            sv.serviceshortdescription = txtServiceShortDescription.Text;
            sv.clientdescription = clientdescription.Text;
            sv.ServiceAttendant = ServiceAttendant.Text;
            sv.SubType = SubType.Text;
            sv.Leadcontact = LeadContact.Text;
            sv.serviceStartDate = serviceStartDate.Text;
            sv.ServiceStart = ServiceStart.Text;
            sv.ServiceEnd = ServiceEnd.Text;
            sv.ServiceExtend = ServiceExtend.Text;
            sv.ServiceActive = ServiceActive.Checked;
            sv.ReferenceProcess = Reference.Text;
            sv.DeptCode = DeptCode.Text;
            sv.ServiceType = ServiceType.Text;
            sv.FullDescription = FullDescription.Text;
            sv.DescriptionDelivery = DescriptionDelivery.Text;
            sv.ContractCode = ContractCode.Text;
            sv.ContractValue = ContractValue.Text;
            sv.StagedPayment = StagedPayment.Checked;
            sv.ServiceTimeLimited = ServiceTimeLimited.Text;
            BOService boService = new BOService();
            boService.UpdateService(sv);

        }
        
        
        }


    }
}